package com.juicygames.undoer.player;

import android.graphics.Color;

import com.juicygames.framework.draw.DrawDepth;
import com.juicygames.framework.draw.DrawService;
import com.juicygames.framework.gamepart.GamePart;
import com.juicygames.framework.property.space.CircleProperty;
import com.juicygames.framework.property.space.ColorProperty;
import com.juicygames.framework.property.space.XVelocity;
import com.juicygames.framework.property.space.YVelocity;
import com.juicygames.framework.type.Circle;
import com.juicygames.undoer.ball.DrawHandler;
import com.juicygames.undoer.ball.OldPosition;
import com.juicygames.undoer.ball.UpdateHandler;
import com.juicygames.undoer.player.property.CanMakeShadow;
import com.juicygames.undoer.player.property.Friction;
import com.juicygames.undoer.player.property.IsTouched;
import com.juicygames.undoer.world.World;

public class Player extends GamePart {
	
	private static final int DRAW_DEPTH = 9;
	private static final float FRICTION = 0.98f;
	private static final int COLOR = Color.RED;
	public static int BIG_RADIUS = 70;
	public static int SMALL_RADIUS = 55;
	
	public Player(GamePart parent) {
		super(parent);
	}
	
	public void load() {
		
		addPart(new Friction(this,FRICTION));
		
		addPart(new IsTouched(this,false));
		addPart(new XVelocity(this,0));
		addPart(new YVelocity(this,0));
		addPart(new OldPosition(this));
		addPart(new CanMakeShadow(this,false));
		
		Circle c = new Circle();
		c.x = World.SCREEN_WIDTH/2;
		c.y = World.SCREEN_HEIGHT/4;
		c.radius = Player.SMALL_RADIUS;
		
		CircleProperty cp = new CircleProperty(this);
		cp.set(c);
		addPart(cp);
		
		addHandler(new UpdateHandler(this));
		
		addHandler(new WallCollideHandler(this));
		
		DrawHandler drawHandler = addHandler(new DrawHandler(this));
		
		addHandler(new TouchHandler(this));
		
		addPart(new ColorProperty(this,COLOR));
		
		addPart(new DrawDepth(this,DRAW_DEPTH));
		GamePart world = getWorld();
		world.getPart(DrawService.class).register(drawHandler);
		
	}
	
}
